package edu.mobbuzz.web.base;

import org.apache.tapestry5.annotations.InjectPage;

import edu.mobbuzz.web.pages.Index;



/**
 * Base page for pages that must not be accessible if the user is not logged in.
 */
public class SecureBasePage extends SimpleBasePage {
	
	@InjectPage
	private Index index;
	
	/**
	 * Validate that the user is logged in.  If not logged in, then redirects to the login page.
	 */
	Object onActivate() {

		if (!isVisitExists() || !getVisit().isLoggedIn()) {
			return index;
		}

		return null;
	}
}
